package cn.cs.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;


public class MySRQUtil {
	public Connection getConn() {

		Connection conn = null;
		// 数据库名称 用户名 密码
		String username = "root";
		String password = "root";

		// JDBC URL
		String url = "jdbc:mysql://192.168.1.254:3306/xlbt";
		try {
			// 加载MySql驱动
			Class.forName("com.mysql.jdbc.Driver");
			// 获取数据库连接
			conn = DriverManager.getConnection(url, username, password);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return conn;
	}

	public void releaseResources(Connection conn, PreparedStatement ps,
			ResultSet rs) {
		try {
			if (null != rs)
				rs.close();
			if (null != ps)
				ps.close();
			if (null != conn)
				conn.close();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
	
}
